//
//  NowBeShowViewCell.m
//  代号：47
//
//  Created by lanou3g on 15/6/30.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "NowBeShowViewCell.h"
#import <UIImageView+WebCache.h>


@implementation NowBeShowViewCell

- (void)dealloc
{
    [_mainImageView release];
    [_introduceImageView release];
    [_nameLabel release];
    [_timeLabel release];
    [_recommendLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        _mainImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreen_width * 0.8, 420 * kScreen_width * 0.8 / 300)];
        _mainImageView.layer.cornerRadius = 20;
        _mainImageView.layer.masksToBounds = YES;
        _mainImageView.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_mainImageView];
        
        
        CGFloat width = _mainImageView.frame.size.width;
        CGFloat height = _mainImageView.frame.size.height;
        _introduceImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, height + kLinePadding, width, 80)];
        _introduceImageView.layer.cornerRadius = 15;
        _introduceImageView.userInteractionEnabled = YES;
//        _introduceImageView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_introduceImageView];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _introduceImageView.frame.size.width - 5 - 50 - 5, 35)];
        _nameLabel.font = [UIFont boldSystemFontOfSize:18];
        _nameLabel.textColor = [UIColor whiteColor];
//        _nameLabel.backgroundColor = [UIColor redColor];
        [_introduceImageView addSubview:_nameLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 35, 120, 30)];
//        _timeLabel.backgroundColor = [UIColor redColor];
        _timeLabel.font = [UIFont boldSystemFontOfSize:15];
        _timeLabel.textColor = [UIColor whiteColor];
        [_introduceImageView addSubview:_timeLabel];
        
        _recommendLabel = [[UILabel alloc] initWithFrame:CGRectMake(_introduceImageView.frame.size.width - 5 - 90, 35, 90, 30)];
        _recommendLabel.textColor = [UIColor whiteColor];
        _recommendLabel.font = [UIFont boldSystemFontOfSize:15];
//        _recommendLabel.backgroundColor = [UIColor redColor];
        [_introduceImageView addSubview:_recommendLabel];
        
        _detailBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        _detailBtn.frame = CGRectMake(_introduceImageView.frame.size.width - 5 - 50,kTopPadding / 2 , 50, 30);
        _detailBtn.layer.cornerRadius = 10;
        [_detailBtn setTitle:@"详情" forState:(UIControlStateNormal)];
        [_detailBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _detailBtn.backgroundColor = RGBColor(24, 84, 0);
        [_introduceImageView addSubview:_detailBtn];
        
        
    }
    
    return self;
}

-(void)setNowModel:(NowMoviesModel *)nowModel{
    
    if (_nowModel != nil) {
        [_nowModel release];
        _nowModel = [nowModel retain];
    }
    
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:nowModel.large]];
    _nameLabel.text = nowModel.title;
    _timeLabel.text = [NSString stringWithFormat:@"%@上映",nowModel.pubdate];
    _recommendLabel.text = [NSString stringWithFormat:@"推荐指数:%.1f",nowModel.rating];
    
    
    
    
    
}




@end
